<?php

class Model
{
	protected $db;
	protected $sql;
	
	public function __construct()
	{
		$this->db = Db::init();
	}
	
	protected function setSql($sql)
	{
		$this->sql = $sql;
	}
	
	public function getAll($data = NULL)
	{
		if(!$this->sql){
			throw new Exception("No SQL Query");
		}
		
		$sth = $this->db->prepare($this->sql);
		$sth->execute($data);
		
		return $sth->fetchAll();
	}
	
	public function getRow($data = NULL)
	{
		if(!$this->sql){
			throw new Exception("No SQL Query");
		}
		
		$sth = $this->db->prepare($this->sql);
		$sth->execute($data);
		
		return $sth->fetch();
	}
	
}